package heap;

import java.util.Comparator;

public class PriorityQueue<E> {
	private BinaryHeap<E> heap;
	
	public PriorityQueue() {
		this(null);
	}
	public PriorityQueue(Comparator<E> comparator) {
		heap = new BinaryHeap<>(comparator);
	}

	/**
	 * 元素的数量
	 * 
	 * @return
	 */
	public int size() {
		return heap.size();
	}

	/**
	 * 队列是否为空
	 * 
	 * @return
	 */
	public boolean isEmpty() {
		return heap.isEmpty();
	}

	/**
	 * 清空队列
	 */
	public void clear() {
		heap.clear();
	}

	/**
	 * 入队
	 * 
	 * @param element
	 */
	public void enQueue(E element) {
		heap.add(element);
	}

	/**
	 * 出队
	 * 
	 * @return
	 */
	public E deQueue() {
		return heap.remove();
	}

	/**
	 * 获取队头元素
	 * 
	 * @return
	 */
	public E front() {
		return heap.get();
	}
}
